﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Drawing.Imaging;
using OpenGL4NET;

namespace WSCore
{
	public class WSTexture2D
	{
		private uint _glTexID;

		public int Width { get; private set; }
		public int Height { get; private set; }

		public WSTexture2D(Bitmap bitmap)
		{
			_glTexID = gl.GenTexture();
			gl.BindTexture(GL.TEXTURE_2D, _glTexID);
			gl.TexImage2D(GL.TEXTURE_2D, 0, bitmap);

			gl.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR);
			gl.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR);

			Width = bitmap.Width;
			Height = bitmap.Height;
		}

		public void Use()
		{
			gl.BindTexture(GL.TEXTURE_2D, _glTexID);
		}
	}
}
